home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-01
/
wtek0693.zip
/
OOPALLEY.ZIP
/
ASSOC.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-04-27
|
929b
|
43 lines
/* Assoc.c -- implementation of key-value association
Function:
Objects of class Assoc associate a key object with a value object. They
are used to implement Dictionaries, which are Sets of Associations.
*/
#include "assoc.h"
#define THIS Assoc
#define BASE LookupKey
// DEFINE_CLASS(THIS,BASE);
DEFINE_CLASS(Assoc, LookupKey);
Assoc::Assoc(const Object& newKey, const Object& newValue)
: LookupKey(newKey)
{
avalue = (Object*)&newValue;
}
Object* Assoc::value() const { return avalue; }
Object* Assoc::value(const Object& newvalue)
{
Object* temp = avalue;
avalue = (Object*)&newvalue;
return temp;
}
void Assoc::deepenShallowCopy()
{
BASE::deepenShallowCopy();
avalue = avalue->deepCopy();
}
void Assoc::printOn(ostream& strm) const
{
strm << className() << "("; BASE::printOn(strm);
strm << "="; avalue->printOn(strm); strm << ")";
}